package vikaa.timelinepackage;

import java.util.ArrayList;

import vikaa.bean.Member_item;
import vikaa.tools.HttpUtil;
import vikaa.tools.StringUtils;
import vikaa.tools.ValueClass;
import vikaa.wowo.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class AdapterGallleryManager extends BaseAdapter
{
    private Context m_context;
    private ArrayList<Member_item> m_infos;
    private LayoutInflater inflater;
    
    public AdapterGallleryManager(Context context, ArrayList<Member_item> infos, LayoutInflater inflater)
    {
        m_context = context;
        m_infos = infos;
        this.inflater = inflater;
    }
    
    public int getCount()
    {
        return m_infos.size();
    }

    public Object getItem(int position)
    {
        return m_infos.get(position);
    }

    public long getItemId(int position)
    {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
    	if (null != convertView)
        {
            return convertView;
        }
        
        Member_item info = m_infos.get(position);
        GalleryManagerView child = new GalleryManagerView(m_context);
        ImageView imageView = new ImageView(m_context);
        if(StringUtils.isEmpty(info.getProfile_image_url())){
        	imageView.setBackgroundResource(R.drawable.wowo_item_cover);
        }else if(info.getProfile_image_url().equals("plus")){
        	imageView.setImageResource(R.drawable.btn_profile_image_plus);
        }else{
        	AsyLoadImg.loadCornerAvater(HttpUtil.HttpUrlComplete(info.getProfile_image_url()), imageView, ValueClass.CORNER_PIXEL);
        }
        child.setContentView(imageView);
        //child.setLabel(info.getFilter_name());
        child.setId(position);
        return child;
	}
	static class Holder {
    	public ImageView pic = null;
    }

}
